package com.fanli.bigdata.mytest

import org.apache.spark.{SparkContext, SparkConf}

/**
 * Created by liangdong.wu on 2016/11/9.
 */
object SparkDemo {
  def main(args: Array[String]) {
    val conf = new SparkConf().setAppName("MySpakDemo1").setMaster("local[*]")
    val sc = new SparkContext(conf)
    //windows file://D:/a.txt
    sc.textFile("file:///D:/Project/P_spark/RecApplication/test_data/ratings02.dat").flatMap(x=>x.split("::")).map(x=>(x,1)).reduceByKey(_+_).collect().foreach(println)
    //sc.textFile("hdfs://115.159.45.213:9000/in/wordcount/in1.txt").flatMap(x=>x.split(" ")).map(x=>(x,1)).reduceByKey(_+_).collect().foreach(println)
    sc.stop()
  }
}
